declare pkg_name=rdoc
declare pkg_base=$(dirname "$0")
declare pkg_version=$(git tag | sort | tail -n 1)
declare pkg_file="${pkg_name}-${pkg_version#v}.vba"

GLOB=(ftdetect/* snippets/* syntax/*)
MANIFEST="Manifest"

source manifest.bk
source version.bk

desc package "Create ${pkg_file}.gz"
task package {
  test -f ${pkg_file}   && rm ${pkg_file}
  test -f ${pkg_file}.* && rm ${pkg_file}.*

  status "Creating package ${pkg_file}.gz"
  vim ${MANIFEST} +":%MkVimball! ${pkg_file} . <cr>" +":q"
  run gzip ${pkg_file}
}

desc install "Install vimball in ${HOME}/.vim/"
task install {
  package
  status "Intalling ${pkg_file}"
  vim ${pkg_file}.gz +":source %" +":q" &> /dev/null
}

desc doc "Build documentation"
task doc {
  status "Building documentation"
  run rdoc --main README.rdoc --title "RDoc.vim" README.rdoc &> /dev/null
}

task push {
  news="github codaset"
  hosts="origin github codaset"
}

desc push:news "Push all changes to hosts"
task push:news {
  status "Pushing new changes to ${news// /, }"
  for remote in ${news}; do
    run git push $remote news
  done
}

desc push:release "Push a new release to hosts"
task push:release {
  status "Pushing new release to ${hosts// /, }"
  for remote in ${hosts}; do
    git push --tags $remote master
  done
}

# vim: filetype=sh

